<template>
	<view class="page">
		<view class="cu-bar bg-white" @click="ChooseImage" v-if="gotImage==0">
			
			<view class="cu-btn round photo bg-blue">
				<image class="bottom-img" src="../../../static/images/photo2.png"></image></view>
			<view style="color: #C1D4E5;background-color: transparent; font-size: 16px;">请拍摄或选择照片</view>
		</view>
		<view class="card bg-white" v-if="gotImage==1" @click="ChooseImage">
			<image class="img" mode="widthFix" :src="card"></image>
			
		</view>
		<view class="cu-bar bg-white bottom" v-if="gotImage==1" @click.stop="">
			<view class="action" @click="SaveImage">
				<view class="cu-btn round sure bg-blue">开始识别</view>
			</view>
		</view>
	<!-- 绑定 -->
	<goReg 
		ref="goReg" 
		:contentHeight="580"
	></goReg>
	</view>
</template>

<script>
	import goReg from "@/components/goReg";
	export default {
		components: {
			goReg,
		},
		data() {
			return {
				gotImage:0,
				level:'',
				card:'',
				imgList:[],
				resultData:'',
				modalName: null,
			};
		},
		methods: {
			
			ChooseImage() {
				
				this.$http.urlImgUpload({
					name:"FVImage", //默认 file
					count:1,//默认 9
					sizeType:"compressed",//默认 ['original', 'compressed']
					// sourceType:"选择相机拍照或相册上传 默认两个都选",//默认 ['album','camera']
					// data:"而外参数" //可不填,
				})
				.then(res => {
					console.log("全部上传完返回结果：",res);
					this.card = res[0].path;
					this.gotImage=1;
					// this.scanImage(res[0].path);
					
				});
			},
			SaveImage(){
				// let uId = uni.getStorageSync('userId');
				let uId =1
				if(uId>"0"&&uId!=undefined){
					uni.setStorageSync('scanParam',{image_path:this.card});
					uni.navigateTo({
						url: '/pages/tabbar/tabbar-2/scanFontResult'
					})
					return;
				}
				
				this.$refs.goReg.showModal('regModal');	
				return;
				
			},
			
		}
	}
</script>

<style>
	.page {
		height: 100%;
		width: 100%;
		background: #FFF;
		position: absolute;
		
	}
	.cu-bar{
		text-align: center;
		display: block;
		margin-top: 250px;
	}
	.img{
		width: 100%;
	}
	.bottom-img{
		width: 27px;
		height: 27px;
	}
	.photo{
		width: 54px;
		height: 54px;
	}
	.card{
		width: 100%;
		height: 100%;
		position: absolute;
		top: 0;
	}
	.sure{
		width: 170px;
		height: 40px;
	}
	.bottom{
		position: fixed !important;
		width: 100%;
		bottom: 20px;
	}
	.page.show {
		overflow: hidden;
	}
	.input{
		text-align: right;
		font-size: 12px;
	}
	
</style>
